package com.gxa.saas.portal.controller.btopfore;


import com.gxa.saas.core.utils.JwtUtil;
import com.gxa.saas.portal.entity.vo.wylvo.OrderVo;
import com.gxa.saas.portal.service.WHomeService;
import com.gxa.saas.portal.service.WSetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/wset")
public class SetManagement {

    @Resource
    private WSetService wSetService;

    @ApiOperation("设置银行卡号")
    @PostMapping("/setBankCard")
    public Map setBankCard(HttpServletRequest request, String bankcard){

        //从shiro中获取当前登录账号
        String sid= JwtUtil.getUsername(request.getAttribute("token1").toString());


        wSetService.setBankCard(BigDecimal.valueOf(Long.parseLong(bankcard)),sid);
        System.out.println(bankcard);
        Map map = new HashMap();
        map.put("msg","设置成功");
        map.put("code",200);

        return map;
    }

    @ApiOperation("显示银行卡号")
    @PostMapping("/selectBankCard")
    public Map selectBankCard(HttpServletRequest request){

        //从shiro中获取当前登录账号
        String sid= JwtUtil.getUsername(request.getAttribute("token1").toString());
        BigDecimal bankCard = wSetService.selectBankCard(sid);
        ArrayList<BigDecimal> list = new ArrayList<>();
        list.add(bankCard);
        Map map = new HashMap();
        map.put("msg","查询成功");
        map.put("code",200);
        map.put("data",list);

        return map;
    }
}
